<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2017/6/6
 * Time: 14:11
 */

defined('In33hao') or exit('Access Invalid!');
class sq_settingModel extends Model{

    public function __construct() {
        parent::__construct('sq_setting');
    }

    public function getBannerInfo($condition){
        return $this->where($condition)->find();
    }

    /**
     * 轮播图列表
     * @param $condition
     * @return mixed
     */
    public function getBannerList($condition){
        return $this->where($condition)->select();
    }

    /**
     * 轮播图数量
     * @param array $condition
     * @return int
     */
    public function getBannerCount($condition) {
        return $this->where($condition)->count();
    }

    /**
     * 新增轮播图
     */
    public function addBanner($data){
        return $this->insert($data);
    }

    /**
     * 编辑轮播图
     */
    public function editBanner($condition,$data){
        return $this->where($condition)->update($data);
    }

    /**
     * 删除
     *
     * @param int $id 记录ID
     * @return bool 布尔类型的返回结果
     */
    public function del($id){
        if (intval($id) > 0){
            $where = " id = '". intval($id) ."'";
            $result = Db::delete('sq_setting',$where);
            return $result;
        }else {
            return false;
        }
    }
}